﻿@model IPagedList<PerformanceAssessment.Models.Assessment>

@{
    ViewBag.Title = "Index";
}
@section Head
{
    <link href="@Url.Content("~/Content/PagedList.css")" rel="stylesheet" type="text/css" />
    <style type="text/css">
        select 
        {
            max-width: 300px;
        }
    </style>
}
@using PagedList.Mvc;
@using PagedList;

<h2>Assessments</h2>
@using (Html.BeginForm("Index", "Assessments", FormMethod.Get))
{  
    <p>
        @Html.Label("Assessment Period:") @Html.DropDownList("assessmentPeriods", "All")
        @Html.Label("Employee:") @Html.DropDownList("employees", "All") 
        @if (ViewBag.userType == PerformanceAssessment.Models.UserType.Administrator)
        {
            @Html.Label("Status:") @Html.DropDownList("status", "All")
        }
        <input type="submit" value="Filter"/>
    </p>
}



<table>
<thead>
    <tr>
        <th>
            Description
        </th>
        <th>
            From
        </th>
        <th>
            To
        </th>
        <th>
            Employee
        </th>
        <th>
            Employee Comments
        </th>
        <th>
            Manager Comments
        </th>
        <th></th>
    </tr>
</thead>
<tbody>
@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.AssessmentPeriod.Description)
        </td>
        <td>
            @Html.Label(item.FromDate.ToShortDateString())
        </td>
        <td>
            @Html.Label(item.ToDate.ToShortDateString())
        </td>
        <td>
            @Html.Label(string.Format("{0} {1} {2}", item.Employee.FirstName, item.Employee.FirstLastName, item.Employee.SecondLastName))
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.EmployeeComments)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ManagerComments)
        </td>
        <td>
            @if (item.ID == 0)
            {
                @Html.ActionLink("Start", "Create", new { periodId = item.IdAssessmentPeriod })
            }
            else
            {
                @Html.ActionLink("Open", "Details", new { assessmentId = item.ID })
            }
        </td>
    </tr>
}
</tbody>
</table>
@Html.PagedListPager(Model, page => Url.Action("Index", new { assessmentPeriods = ((SelectList)ViewBag.assessmentPeriods).SelectedValue, employees = ((SelectList)ViewBag.employees).SelectedValue, page = page, }), new PagedListRenderOptions { LinkToFirstPageFormat = "<<", LinkToPreviousPageFormat = "<", LinkToNextPageFormat = ">", LinkToLastPageFormat = ">>", DisplayLinkToFirstPage = true, DisplayLinkToLastPage = true })
